package com.example.hehecat.yuejian1.mvp.model;

import com.example.hehecat.yuejian1.http.RetrofitHttp;
import com.example.hehecat.yuejian1.mvp.contract.MasterInfoContract;
import com.example.hehecat.yuejian1.mvp.model.bean.MasterBean;
import com.example.hehecat.yuejian1.mvp.model.bean.MasterLessonBean;
import com.example.hehecat.yuejian1.mvp.model.bean.SuccessBean;

import java.util.List;

import okhttp3.OkHttpClient;
import retrofit2.Callback;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class MasterInfoModel implements MasterInfoContract.Model {
    @Override
    public void getMaster(int master_id, Subscriber<MasterBean> subscriber) {
        OkHttpClient.Builder builder = new OkHttpClient.Builder();
        RetrofitHttp.getRetrofit(builder).getMasterInfo(master_id)
                .subscribeOn(Schedulers.newThread())
                .observeOn(AndroidSchedulers.mainThread())
            .subscribe(subscriber);
}

    @Override
    public void getLesson(int master_id, Subscriber<List<MasterLessonBean>> subscriber) {
        OkHttpClient.Builder builder = new OkHttpClient.Builder();
        RetrofitHttp.getRetrofit(builder).getMasterlesson(master_id)
                .subscribeOn(Schedulers.newThread())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    @Override
    public void collectMaster(int master_id, int user_id, Callback<SuccessBean> callback) {
        OkHttpClient.Builder builder = new OkHttpClient.Builder();
        RetrofitHttp.getRetrofit(builder).collectMaster(user_id, master_id)
                .enqueue(callback);
    }

    @Override
    public void isMasterCollect(int master_id, int user_id, Callback<SuccessBean> callback) {
        OkHttpClient.Builder builder = new OkHttpClient.Builder();
        RetrofitHttp.getRetrofit(builder).isMasterCollect(user_id, master_id)
                .enqueue(callback);
    }


}
